//
//  QZHongBaoDetailsVC.m
//  shortvideoplay
//
//  Created by tikeios_002 on 2024/7/12.
//

#import "QZHongBaoDetailsVC.h"
#import "QZHongBaoDetailsHeaderCell.h"
#import "QZHongBaoDetailsListCell.h"
#import "QZHongBaoJifenDetailsVC.h"
#import "QZHongBaoXianjinDetailsVC.h"
#import "QZHongBaoTixianVC.h"
#import "QZHongBaoSignView.h"
#import "DJUploadVC.h"
#import "CSJADLoading.h"
#import "GDTRewardVideoAd.h"
#import "MyShareListVC.h"


@interface QZHongBaoDetailsVC ()<BUNativeExpressRewardedVideoAdDelegate,UICollectionViewDelegate,UICollectionViewDataSource,GDTRewardedVideoAdDelegate>
@property (nonatomic, strong) UICollectionView * hongbaoCollection;
@property (nonatomic, strong) NSDictionary * moneyDictionary;
@property (nonatomic, strong) NSDictionary * signListDictionary;
@property (nonatomic, strong) NSArray * listArr;
@property (nonatomic, strong) BUNativeExpressRewardedVideoAd *jiliManager;
@property (strong, nonatomic)UIView * adView;
@property (strong, nonatomic)QZHongBaoSignView * signView;
@property (assign, nonatomic)BOOL isOneShow;
@property (assign, nonatomic)BOOL isSignAd;
@property (nonatomic, strong) GDTRewardVideoAd *rewardVideoAd;
@end

@implementation QZHongBaoDetailsVC

-(void)showTextViewNavViewTo1{
    NSMutableArray * showTextViewNavViewNameArrTo1 = [NSMutableArray new];
    UIView * showTextViewNavViewViewTo1 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
    showTextViewNavViewViewTo1.clipsToBounds = YES;
       UILabel * oldshowSSSSTip = [[UILabel alloc]init];
    oldshowSSSSTip.clipsToBounds = YES;
    oldshowSSSSTip.text = @"kass显示区";
    oldshowSSSSTip.textColor = ColorHex(@"#f0f0f0");
    oldshowSSSSTip.textAlignment = NSTextAlignmentCenter;
    oldshowSSSSTip.font = [UIFont systemFontOfSize:28];
    oldshowSSSSTip.hidden = YES;
    [self.view addSubview:oldshowSSSSTip];
    [self.view addSubview:showTextViewNavViewViewTo1];
    UILabel * showTextViewNavViewLabelTo1 = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
    NSInteger showTextViewNavViewNumberTo1 = arc4random_uniform(20);
    NSLog(@"：%ld", (long)showTextViewNavViewNumberTo1);
    showTextViewNavViewLabelTo1.text = [NSString stringWithFormat:@"%ld",(long)showTextViewNavViewNumberTo1];
    [showTextViewNavViewLabelTo1 addSubview:showTextViewNavViewLabelTo1];
    
    UIImageView * showTextViewNavViewLabelTo2 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
    [showTextViewNavViewViewTo1 addSubview:showTextViewNavViewLabelTo2];
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
}
- (void)showOldAddNavViewToMainOldView1{
    UIView * oldBgSS = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
    oldBgSS.clipsToBounds = YES;
       UILabel * oldshowSSSSTip = [[UILabel alloc]init];
    oldshowSSSSTip.clipsToBounds = YES;
    oldshowSSSSTip.text = @"kass显示区";
    oldshowSSSSTip.textColor = ColorHex(@"#f0f0f0");
    oldshowSSSSTip.textAlignment = NSTextAlignmentCenter;
    oldshowSSSSTip.font = [UIFont systemFontOfSize:28];
    oldshowSSSSTip.hidden = YES;
    [self.view addSubview:oldshowSSSSTip];
    [self.view addSubview:oldBgSS];
    
    UIButton * sendBtn = [[UIButton alloc]initWithFrame:CGRectMake(KScreen_W-75, kStatusBarHeight+10, 60, 46)];
    sendBtn.layer.cornerRadius = 3;
    sendBtn.backgroundColor = [UIColor whiteColor];
    [sendBtn setTitle:@"发送" forState:UIControlStateNormal];
    [sendBtn setTitleColor:ColorHex(@"#333333") forState:UIControlStateNormal];
    sendBtn.titleLabel.font = [UIFont systemFontOfSize:16];
    [sendBtn addTarget:self action:@selector(sendTap) forControlEvents:UIControlEventTouchUpInside];
    [oldBgSS addSubview:sendBtn];
    
    UIView * sendBg = [[UIView alloc]initWithFrame:CGRectMake(15, kStatusBarHeight+66, KScreen_W-30, (KScreen_H-KSafeAreaBottomHeight-25-(kStatusBarHeight+66))/2)];
    sendBg.backgroundColor = [UIColor whiteColor];
    sendBg.layer.cornerRadius = 3;
    [oldBgSS addSubview:sendBg];
    
    UILabel * sendTip = [[UILabel alloc]initWithFrame:CGRectMake(0, (sendBg.frame.size.height-40)/2, sendBg.frame.size.width, 40)];
    sendTip.text = @"发送区";
    sendTip.textColor = ColorHex(@"#f0f0f0");
    sendTip.textAlignment = NSTextAlignmentCenter;
    sendTip.font = [UIFont systemFontOfSize:28];
    [sendBg addSubview:sendTip];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    _isOneShow = YES;
    UIButton * back = [[UIButton alloc]initWithFrame:CGRectMake(11, 2+kStatusBarHeight, 40, 40)];
    [back setImage:KImageNamed(@"ico_nav_back_wite") forState:UIControlStateNormal];
    [back addTarget:self action:@selector(backTap) forControlEvents:UIControlEventTouchUpInside];
       UILabel * oldshowSSSSTip = [[UILabel alloc]init];
    oldshowSSSSTip.clipsToBounds = YES;
    oldshowSSSSTip.text = @"kass显示区";
    oldshowSSSSTip.textColor = ColorHex(@"#f0f0f0");
    oldshowSSSSTip.textAlignment = NSTextAlignmentCenter;
    oldshowSSSSTip.font = [UIFont systemFontOfSize:28];
    oldshowSSSSTip.hidden = YES;
    [self.view addSubview:oldshowSSSSTip];
    [self.view addSubview:back];
    
    UILabel * navTitle = [[UILabel alloc]initWithFrame:CGRectMake(KScreen_W/2-100, kStatusBarHeight, 200, 44)];
    navTitle.text = @"赚钱任务";
    navTitle.textColor = UIColor.whiteColor;
    navTitle.font = [UIFont systemFontOfSize:18 weight:UIFontWeightMedium];
    navTitle.textAlignment = NSTextAlignmentCenter;
       UILabel * oldshowSSSSTip1 = [[UILabel alloc]init];
    oldshowSSSSTip1.clipsToBounds = YES;
    oldshowSSSSTip1.text = @"kass显示区";
    oldshowSSSSTip1.textColor = ColorHex(@"#f0f0f0");
    oldshowSSSSTip1.textAlignment = NSTextAlignmentCenter;
    oldshowSSSSTip1.font = [UIFont systemFontOfSize:28];
    oldshowSSSSTip1.hidden = YES;
    [self.view addSubview:oldshowSSSSTip1];
    [self.view addSubview:navTitle];
    
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
    flowLayout.minimumLineSpacing = 0.0;
    flowLayout.minimumInteritemSpacing = 0.0;
    flowLayout.footerReferenceSize = CGSizeZero;
    flowLayout.headerReferenceSize = CGSizeZero;
    flowLayout.sectionInset = UIEdgeInsetsZero;
    flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
    
    flowLayout.itemSize = CGSizeMake([UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
    //创建collectionView 通过一个布局策略layout来创建
    self.hongbaoCollection = [[UICollectionView alloc]initWithFrame:CGRectMake(0, KNav_H, KScreen_W, KScreen_H-55-KNav_H) collectionViewLayout:flowLayout];
    self.hongbaoCollection.backgroundColor = viewback_black;
    if (@available(iOS 11.0, *)) {
        self.hongbaoCollection.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }
    //代理设置
    self.hongbaoCollection.scrollsToTop = NO;
    self.hongbaoCollection.delegate=self;
    self.hongbaoCollection.dataSource=self;
    self.hongbaoCollection.pagingEnabled = YES;
    self.hongbaoCollection.showsVerticalScrollIndicator = NO;
    self.hongbaoCollection.showsHorizontalScrollIndicator = NO;
    self.hongbaoCollection.hidden = YES;
    //注册item类型 这里使用系统的类型
    [self.hongbaoCollection registerNib:[UINib nibWithNibName:@"QZHongBaoDetailsHeaderCell" bundle:nil] forCellWithReuseIdentifier:@"QZHongBaoDetailsHeaderCell"];
    [self.hongbaoCollection registerNib:[UINib nibWithNibName:@"QZHongBaoDetailsListCell" bundle:nil] forCellWithReuseIdentifier:@"QZHongBaoDetailsListCell"];
    
       UILabel * oldshowSSSSTip2 = [[UILabel alloc]init];
    oldshowSSSSTip2.clipsToBounds = YES;
    oldshowSSSSTip2.text = @"kass显示区";
    oldshowSSSSTip2.textColor = ColorHex(@"#f0f0f0");
    oldshowSSSSTip2.textAlignment = NSTextAlignmentCenter;
    oldshowSSSSTip2.font = [UIFont systemFontOfSize:28];
    oldshowSSSSTip2.hidden = YES;
    [self.view addSubview:oldshowSSSSTip2];
    [self.view addSubview:self.hongbaoCollection];
//    [self ADJiliAdsAdRequest];
    [self activityTaskListRequest:NO];
    
    _adView = [[UIView alloc]init];
    _adView.layer.cornerRadius = 6;
    _adView.clipsToBounds = YES;
    _adView.backgroundColor = [UIColor clearColor];
    _adView.frame = CGRectMake(0, KScreen_H-45, KScreen_W, 0);
    [self.view addSubview:_adView];
    
    KWeakSelf
    [CSJADLoading share].BannerAdsLoadFish = ^(id  _Nullable bannerView) {
        if(bannerView != nil && weakSelf.adView){
            weakSelf.adView.frame = CGRectMake(0, KScreen_H-45, KScreen_W, 45);
            [weakSelf.adView addSubview:bannerView];
            [bannerView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.edges.equalTo(weakSelf.adView);
            }];
            [UIView animateWithDuration:0.3 animations:^{
                [weakSelf.view layoutIfNeeded];
            }];
        }
    };
    [CSJADLoading ADBannerAdRequest:self];
}
- (void)activityTaskListRequest:(BOOL)isChange{
    KMutableDic(sendDic)
    KWeakSelf
    [YBNetBase activityTaskListRequest:sendDic successBlock:^(NSDictionary * _Nonnull data, NSInteger code, NSString * _Nonnull msg) {
        if(code == 200){
            weakSelf.moneyDictionary = data;
            weakSelf.listArr = data[@"task_list"];
            weakSelf.signListDictionary = data[@"sign_in_list"];
            if([weakSelf.signListDictionary[@"today_sign"] intValue] == 0 && weakSelf.isOneShow){
                weakSelf.signView = [[QZHongBaoSignView alloc]initWithFrame:CGRectMake(0, 0, KScreen_W, KScreen_H)];
                weakSelf.signView.dataDic = weakSelf.signListDictionary;
                [weakSelf.view addSubview:weakSelf.signView];
                weakSelf.signView.QZHongBaoSignBlock = ^{
                    [weakSelf activityTaskListRequest:YES];
                };
                weakSelf.signView.QZHongBaoSignSeeAdBlock = ^{
                    weakSelf.isSignAd = YES;
                    [weakSelf ADJiliAdsAdRequest];
                };
            }
            weakSelf.isOneShow = NO;
            [weakSelf.hongbaoCollection reloadData];
            weakSelf.hongbaoCollection.hidden = NO;
            if(isChange){
                weakSelf.signView.dataDic = weakSelf.signListDictionary;
            }
        }else{
            [YBMsgPop showPop:msg];
        }
    }];
}
// 创建广告对象
- (void)ADJiliAdsAdRequest {
    [SVProgressHUDTool showWithStatus:nil];
    [QZUserInfoModel adRequestType:^(NSInteger type) {
//        if(type == 0){
            BUAdSlot *adslot = [[BUAdSlot alloc]init];
            adslot.ID = @"958914176"; // 聚合维度通过广告位ID发起请求，仅接入CSJ广告通过代码位ID发起请求
            
            BURewardedVideoModel *model = [[BURewardedVideoModel alloc] init];
            model.userId = [NSString stringWithFormat:@"%@",[QZUserInfoModel share].mid]; // 用户唯一标识
            model.rewardName = [QZUserInfoModel share].nickname; // 奖励名称
            model.rewardAmount = 100;  // 奖励数量
        //    model.extra = @{@"key1" : @"value1"}.BUYY_modelToJSONString; // 透传参数
            self.jiliManager = [[BUNativeExpressRewardedVideoAd alloc] initWithSlot:adslot rewardedVideoModel:model];
            self.jiliManager.delegate = self;
            [self.jiliManager loadAdData];
//        }else{
//            self.rewardVideoAd = [[GDTRewardVideoAd alloc] initWithPlacementId:@""];
//            self.rewardVideoAd.delegate = self;
//            self.rewardVideoAd.videoMuted = NO; // 设置激励视频是否静音
//            [self.rewardVideoAd loadAd];
//        }
    }];
}
- (void)backTap{
    [self.navigationController popViewControllerAnimated:YES];
}
#pragma mark uitableview delege
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
    return 2;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    if(section == 0){
        return 1;
    }else{
        if([[QZUserInfoModel share].invite_switch intValue] == 1){
            return self.listArr.count+2;
        }else{
            return self.listArr.count+1;
        }
        
    }
}
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    if(indexPath.section == 0){
        QZHongBaoDetailsHeaderCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"QZHongBaoDetailsHeaderCell" forIndexPath:indexPath];
        cell.jibiLabel.text = [NSString stringWithFormat:@"%@",self.moneyDictionary[@"integration"]];
        cell.xianjinLabel.text = [NSString stringWithFormat:@"%@",self.moneyDictionary[@"integration_wallet"]];
        KWeakSelf
        cell.QZHongBaoDetailsHeaderBlock = ^(NSInteger index) {
            if (index == 0){
                QZHongBaoJifenDetailsVC * details = [[QZHongBaoJifenDetailsVC alloc]init];
                [weakSelf.navigationController pushViewController:details animated:YES];
            }else if(index == 1){
                QZHongBaoXianjinDetailsVC * details = [[QZHongBaoXianjinDetailsVC alloc]init];
                [weakSelf.navigationController pushViewController:details animated:YES];
            }else if (index == 2){
                QZHongBaoTixianVC * tixian = [[QZHongBaoTixianVC alloc]init];
                [weakSelf.navigationController pushViewController:tixian animated:YES];
                tixian.QZHongBaoTixianBlock = ^{
                    [weakSelf activityTaskListRequest:NO];
                };
            }
        };
        return cell;
    }else{
        QZHongBaoDetailsListCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"QZHongBaoDetailsListCell" forIndexPath:indexPath];
        if(indexPath.row == 0){
            cell.typeImage.image = KImageNamed(@"ico_hongbao_qidao");
            cell.typeWdith.constant = 22;
            cell.typeHeight.constant = 22;
            cell.typeName.text = @"签到";
            cell.typeButton.userInteractionEnabled = YES;
            cell.typeTip.text = [NSString stringWithFormat:@"已连续签到%@天",self.signListDictionary[@"sign_in_days"]];
            if([self.signListDictionary[@"today_sign"] intValue] == 1){
                [cell.typeButton setTitle:@"去看看" forState:UIControlStateNormal];
                cell.typeButton.backgroundColor = ColorHex_Alpha(@"f2f3f4", 1);
                [cell.typeButton setTitleColor:ThreeColor forState:UIControlStateNormal];
                cell.numberLabel.text = [self seeAdVideo];
//                cell.typeButton.userInteractionEnabled = NO;
            }else{
                for (int i=0; i<[self.signListDictionary[@"list"] count]; i++) {
                    if([self.signListDictionary[@"list"][i][@"is_today"] intValue] == 1){
                        cell.numberLabel.text = [NSString stringWithFormat:@"+%@",self.signListDictionary[@"list"][i][@"integration"]];
                        break;
                    }
                }
                [cell.typeButton setTitle:@"去签到" forState:UIControlStateNormal];
                cell.typeButton.backgroundColor = MainColor;
                [cell.typeButton setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
//                cell.typeButton.userInteractionEnabled = YES;
            }
        }else if(indexPath.row == self.listArr.count+1 && [[QZUserInfoModel share].invite_switch intValue] == 1) {
            cell.typeImage.image = KImageNamed(@"ico_mine_more_share");
            cell.typeWdith.constant = 22;
            cell.typeHeight.constant = 22;
            cell.typeName.text = @"邀请好友看视频,一起领取奖励";
            cell.numberLabel.text = @"";
            cell.typeTip.text = @"邀请好友填写邀请码后一起领取奖励";
            [cell.typeButton setTitle:@"去邀请" forState:UIControlStateNormal];
        }else{
            if ([self.listArr[indexPath.row-1][@"func_type"] isEqualToString:@"share_user"]) {
                cell.typeImage.image = KImageNamed(@"ico_mine_more_share");
                cell.typeWdith.constant = 22;
                cell.typeHeight.constant = 22;
            }else if ([self.listArr[indexPath.row-1][@"func_type"] isEqualToString:@"watch_incentive_adv"]) {
                cell.typeImage.image = KImageNamed(@"ico_hongbao_seead");
                cell.typeWdith.constant = 40;
                cell.typeHeight.constant = 40;
            }else if ([self.listArr[indexPath.row-1][@"func_type"] isEqualToString:@"like_video"]) {
                cell.typeImage.image = KImageNamed(@"ico_hongbao_dianzan");
                cell.typeWdith.constant = 22;
                cell.typeHeight.constant = 22;
            }else if ([self.listArr[indexPath.row-1][@"func_type"] isEqualToString:@"comment_video"]) {
                cell.typeImage.image = KImageNamed(@"ico_hongbao_pinglun");
                cell.typeWdith.constant = 22;
                cell.typeHeight.constant = 22;
            }else if ([self.listArr[indexPath.row-1][@"func_type"] isEqualToString:@"create_video"]) {
                cell.typeImage.image = KImageNamed(@"ico_hongbao_yifabushipin");
                cell.typeWdith.constant = 22;
                cell.typeHeight.constant = 22;
            }
            if([self.listArr[indexPath.row-1][@"title"] isEqualToString:@"观看3条激励广告"]){
                cell.typeName.text = @"观看1条激励广告";
            }else{
                cell.typeName.text = self.listArr[indexPath.row-1][@"title"];
            }
            
            cell.numberLabel.text = [NSString stringWithFormat:@"+%@",self.listArr[indexPath.row-1][@"integration"]];
            cell.typeTip.text = [NSString stringWithFormat:@"已完成%@/%@",self.listArr[indexPath.row-1][@"target_value"],self.listArr[indexPath.row-1][@"task_value"]];
            if([self.listArr[indexPath.row-1][@"status"] intValue] == 1){
                [cell.typeButton setTitle:@"已完成" forState:UIControlStateNormal];
                cell.typeButton.backgroundColor = ColorHex_Alpha(@"f2f3f4", 1);
                [cell.typeButton setTitleColor:ThreeColor forState:UIControlStateNormal];
                cell.typeButton.userInteractionEnabled = NO;
            }else{
                [cell.typeButton setTitle:self.listArr[indexPath.row-1][@"button_txt"] forState:UIControlStateNormal];
                cell.typeButton.backgroundColor = MainColor;
                [cell.typeButton setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
                cell.typeButton.userInteractionEnabled = YES;
            }
        }
        KWeakSelf
        cell.QZHongBaoDetailsListBlock = ^{
            if(indexPath.row == 0){
                weakSelf.signView = [[QZHongBaoSignView alloc]initWithFrame:CGRectMake(0, 0, KScreen_W, KScreen_H)];
                weakSelf.signView.dataDic = weakSelf.signListDictionary;
                [weakSelf.view addSubview:weakSelf.signView];
                weakSelf.signView.QZHongBaoSignBlock = ^{
                    [weakSelf activityTaskListRequest:YES];
                };
                weakSelf.signView.QZHongBaoSignSeeAdBlock = ^{
                    weakSelf.isSignAd = YES;
                    [weakSelf ADJiliAdsAdRequest];
                };
//                [self presentViewController:vc animated:YES completion:^{
//                    
//                }];
//                [weakSelf.navigationController pushViewController:vc animated:YES];
            }else if(indexPath.row == self.listArr.count+1) {
                MyShareListVC * list = [[MyShareListVC alloc]init];
                [weakSelf.navigationController pushViewController:list animated:YES];
            }else{
                if ([weakSelf.listArr[indexPath.row-1][@"func_type"] isEqualToString:@"share_user"]) {
                    //分享
                    [Tools iosSystemShare:@[[NSURL URLWithString:SHAREURL]] sourceView:weakSelf success:^{
                        KMutableDic(sendDic)
                        [YBNetBase integrationwatchShareRequest:sendDic successBlock:^(NSDictionary * _Nonnull data, NSInteger code, NSString * _Nonnull msg) {
                            if(code == 200){
                                [weakSelf activityTaskListRequest:NO];
                            }else{
                                [YBMsgPop showPop:msg];
                            }
                        }];
                    } fail:^{
                        [YBMsgPop showPop:@"分享失败"];
                    }];
                } else if ([weakSelf.listArr[indexPath.row-1][@"func_type"] isEqualToString:@"watch_incentive_adv"]) {
                    //观看激励视频
                    weakSelf.isSignAd = NO;
                    [weakSelf ADJiliAdsAdRequest];
                }
                else if ([weakSelf.listArr[indexPath.row-1][@"func_type"] isEqualToString:@"like_video"]) {
                    //视频点赞
                    [weakSelf backTap];
                }
                else if ([weakSelf.listArr[indexPath.row-1][@"func_type"] isEqualToString:@"comment_video"]) {
                    //视频评论
                    [weakSelf backTap];
                }
                else if ([weakSelf.listArr[indexPath.row-1][@"func_type"] isEqualToString:@"create_video"]) {
                    //发布视频
                    DJUploadVC * upload = [[DJUploadVC alloc]init];
                    upload.modalPresentationStyle = UIModalPresentationFullScreen;
                    [weakSelf presentViewController:upload animated:YES completion:nil];
                }
            }
        };
        
        return cell;
    }
}
- (NSString *)seeAdVideo{
    NSString * timestr = [Tools getNowDayTimeTimestamp];
    NSDictionary * num_dic = [[NSUserDefaults standardUserDefaults] objectForKey:@"hongbao_sign_number"];
    if(num_dic == nil){
        return @"1022";
    }else{
        if([[num_dic allKeys] containsObject:timestr]){
            if([num_dic[timestr][@"number"] intValue] == 3){
                for (int i=0; i<[self.signListDictionary[@"list"] count]; i++) {
                    if([self.signListDictionary[@"list"][i][@"is_today"] intValue] == 1){
                        if(i == [self.signListDictionary[@"list"] count]){
                            return [NSString stringWithFormat:@"明日+%@",self.signListDictionary[@"list"][0][@"integration"]];
                        }else{
                            return [NSString stringWithFormat:@"明日+%@",self.signListDictionary[@"list"][i+1][@"integration"]];
                        }
                    }
                }
            }else{
                return [NSString stringWithFormat:@"+%@",num_dic[timestr][@"money"]];
            }
        }else{
            NSMutableDictionary * sum_dic = [[NSMutableDictionary alloc]initWithDictionary:num_dic];
            int money = 1022-([sum_dic[@"number"] intValue]%3)*180;
            money = money-[sum_dic[timestr][@"number"] intValue]*200;
            int x = arc4random() % 100;
            if(money < 500){
                money = 500;
            }
            money=money+x;
            sum_dic[timestr] = @{@"number":@(0),@"money":@(money)};
            [[NSUserDefaults standardUserDefaults] setValue:sum_dic forKey:@"hongbao_sign_number"];
            return [NSString stringWithFormat:@"+%d",money];
        }
    }
    return @"";
}
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
    if(section == 0){
        return 0;
    }else{
        return 0;
    }
}

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
    if(section == 0){
        return 0;
    }else{
        return 0;
    }
}
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView
 layout:(UICollectionViewLayout *)collectionViewLayout
insetForSectionAtIndex:(NSInteger)section
{
    if(section == 0){
        return UIEdgeInsetsMake(0, 0, 0, 0);
    }else{
        return UIEdgeInsetsMake(0, 0, 0, 0);
    }
    
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    if(indexPath.section == 0){
        return CGSizeMake(KScreen_W, 160);
    }else{
        return CGSizeMake(KScreen_W, 76);
    }
    
    
}
- (void)showTextViewSubViewToViewTo1:(UIView * )subView{

    UIView * showTextViewSubViewTo1 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
    showTextViewSubViewTo1.clipsToBounds = YES;
    [subView addSubview:showTextViewSubViewTo1];
    UILabel * showTextViewSubViewLabelTo2 = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
    showTextViewSubViewLabelTo2.text = @"56464645";
    [showTextViewSubViewTo1 addSubview:showTextViewSubViewLabelTo2];
    
    UIImageView * showTextViewSubViewTo2 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
    [subView addSubview:showTextViewSubViewTo2];

}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    if(indexPath.section == 0){
        
        
    }else{
        
    }
}

#pragma mark 激励广告代理
- (void)nativeExpressRewardedVideoAdDidLoad:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd {
    
}

- (void)nativeExpressRewardedVideoAdDidDownLoadVideo:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd {
    //在此回调方法后进行广告的展示，可保证播放流畅和展示流畅，用户体验更好。
    [SVProgressHUDTool dismiss];
    if (self.jiliManager) {
        [self.jiliManager showAdFromRootViewController:self];
    }
}


- (void)nativeExpressRewardedVideoAd:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd didFailWithError:(NSError *_Nullable)error {
    [SVProgressHUDTool dismiss];
    [YBMsgPop showPop:@"广告加载失败"];
}

- (void)nativeExpressRewardedVideoAdViewRenderFail:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd error:(NSError *_Nullable)error {
    [SVProgressHUDTool dismiss];
    [YBMsgPop showPop:@"广告加载失败"];
}

- (void)nativeExpressRewardedVideoAdDidClose:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd {
    //在此回调方法中可进行广告的置空操作
    self.jiliManager = nil;
    if(self.isSignAd){
        KWeakSelf
        [self.signView signAdSeeFish:^(bool isfish) {
            if(isfish){
                [weakSelf activityTaskListRequest:NO];
            }
        }];
    }else{
        KWeakSelf
        KMutableDic(sendDic)
        [YBNetBase integrationwatchAdvRequest:sendDic successBlock:^(NSDictionary * _Nonnull data, NSInteger code, NSString * _Nonnull msg) {
            if(code == 200){
                [weakSelf activityTaskListRequest:NO];
            }else{
                [YBMsgPop showPop:msg];
            }
        }];
    }
}

- (void)nativeExpressRewardedVideoAdServerRewardDidFail:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd  {
}

- (void)nativeExpressRewardedVideoAdServerRewardDidFail:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd error:(NSError *_Nullable)error {
    
}
-(void)nativeExpressRewardedVideoAdDidClick:(BUNativeExpressRewardedVideoAd *)rewardedVideoAd{
    NSLog(@"");
}
#pragma mark ylh 代理
- (void)gdt_rewardVideoAdVideoDidLoad:(GDTRewardVideoAd *)rewardedVideoAd
{
    NSLog(@"视频文件加载成功");
    [self.rewardVideoAd showAdFromRootViewController:self];
    NSLog(@"=====激励广告奖励：%ld",[rewardedVideoAd eCPM]);
}
- (void)gdt_rewardVideoAdDidClose:(GDTRewardVideoAd *)rewardedVideoAd{
    
}
- (void)gdt_rewardVideoAdDidRewardEffective:(GDTRewardVideoAd *)rewardedVideoAd info:(NSDictionary *)info{
    if(self.isSignAd){
        KWeakSelf
        [self.signView signAdSeeFish:^(bool isfish) {
            if(isfish){
                [weakSelf activityTaskListRequest:NO];
            }
        }];
    }else{
        KWeakSelf
        KMutableDic(sendDic)
        [YBNetBase integrationwatchAdvRequest:sendDic successBlock:^(NSDictionary * _Nonnull data, NSInteger code, NSString * _Nonnull msg) {
            if(code == 200){
                [weakSelf activityTaskListRequest:NO];
            }else{
                [YBMsgPop showPop:msg];
            }
        }];
    }
    
}
- (void)gdt_rewardVideoAdDidPlayFinish:(GDTRewardVideoAd *)rewardedVideoAd{

}
- (void)gdt_rewardVideoAd:(GDTRewardVideoAd *)rewardedVideoAd didFailWithError:(NSError *)error
{
    if (error.code == 4014) {
        NSLog(@"请拉取到广告后再调用展示接口");
    } else if (error.code == 4016) {
        NSLog(@"应用方向与广告位支持方向不一致");
    } else if (error.code == 5012) {
        NSLog(@"广告已过期");
    } else if (error.code == 4015) {
        NSLog(@"广告已经播放过，请重新拉取");
    } else if (error.code == 5002) {
        NSLog(@"视频下载失败");
    } else if (error.code == 5003) {
        NSLog(@"视频播放失败");
    } else if (error.code == 5004) {
        NSLog(@"没有合适的广告");
    }
    NSLog(@"ERROR: %@", error);
}
@end
